//
//  SmallKnowledgeCollectionView.m
//  MyProject
//
//  Created by dllo on 15/11/1.
//  Copyright (c) 2015年 蓝鸥0825. All rights reserved.
//

#import "SmallKnowledgeCollectionView.h"


#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height

@implementation SmallKnowledgeCollectionView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self create];
    }
    return self;
}


- (void)create{
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH / 10 * 3, HEIGHT) style:UITableViewStylePlain];
    [self addSubview:self.tableView];
    [self.tableView release];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
     self.array = [NSMutableArray arrayWithObjects:@"早餐", @"午餐", @"下午茶", @"晚餐", @"夜宵", nil];
    
    
    self.practicalView = [[PracticalView alloc] initWithFrame:CGRectMake( WIDTH / 10 * 3, 0, WIDTH / 10 * 7, HEIGHT)];
    [self addSubview:self.practicalView];
    
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  
    return self.array.count;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *reuse = @"reuse";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse];
    }
    cell.textLabel.font = [UIFont systemFontOfSize:15];
    cell.textLabel.text = self.array[indexPath.row];
    return  cell;
    
}



//      重写 set 方法
- (void)setVC:(UIViewController *)VC
{
    _VC = VC;
    self.practicalView.VC = self.VC;
}




- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    
    //      属性传值必须放在点击方法
//    self.practicalView.VC = self.VC;
    if (indexPath.row == 0) {
        
        self.practicalView.array = self.arrZao;
        [self.practicalView.collection reloadData];

        
    }else if (indexPath.row == 1){
        
        self.practicalView.array = self.arrWu;
        [self.practicalView.collection reloadData];

        
    }else if(indexPath.row == 2){
        
        self.practicalView.array = self.arrXiaWuCha;
        [self.practicalView.collection reloadData];

        
    }else if(indexPath.row == 3){

        self.practicalView.array = self.arrWan;
        [self.practicalView.collection reloadData];
 
        
    }else{

        self.practicalView.array = self.arrYeXiao;
        [self.practicalView.collection reloadData];

        
    }
    
    
    
    
    
}



@end
